//
// Created by 朱语 on 2022/7/26.
//

#ifndef DS_TREE_H
#define DS_TREE_H

#include <vector>
#include <iostream>
#include "TreeNode.h"
using namespace std;

class tree {
public:
    TreeNode* root;

    tree();
    ~tree();
    void build(vector<int>& preorder, vector<int>& inorder);
    //中序遍历
    void inorderTraversal();
    //先序遍历
    void preorderTraversal();
    //后序遍历
    void postorderTraversal();
    //层序遍历
    void levelTraversal();

private:
    void postDelete(TreeNode** _root);
    TreeNode* buildTree(vector<int>& preorder,vector<int> inorder,int pstart,int pend,int istart,int iend);

    //递归
    void preorder(TreeNode* root);
    void inorder(TreeNode* root);
    void postorder(TreeNode* root);

    //迭代
    void preorder_iter();
    void inorder_iter();
    void postorder_iter();
    void level_iter();

};


#endif //DS_TREE_H
